<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:86:"/data/www/html/web2017/public_html/../application/index/view/index/article_detail.html";i:1498745122;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title><?php echo $article['title']; ?>-<?php echo $user_info['nickname']; ?>-树人号</title>
    <link href="__STATIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/weibo/css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/style/weui.min.css">
    <link rel="stylesheet" href="__STATIC__/style/cmgd.css">
    <script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="__STATIC__/weibo/js/jquery.json.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/js/layer/layer.js" ></script>
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/admin/js/jquery.form.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>


<style>
    .content{padding:10px;}
    .title{width:100%;font-size:22px; font-weight: bold;}
    .title1{width:100%;font-size:14px; color: #ccc;padding: 8px 0;}
    .zan{ margin:0 auto; height:30px; line-height:30px;text-align: center; }
    .num{height: 30px; line-height:30px;float:left;}
    .pl{padding-left:20%}
    .foot{width:100%; position: fixed;height:40px; bottom: 0;background:#fff;line-height:40px;}
    .footli{width:33%;float:left;text-align:center;line-height:40px;padding: 0; margin: 0 auto;}
    .fleft{float: left; text-align: center;}
    .fleft a {width:40px;height:30px;}
    a{ text-decoration:none;}
    .comm{width: 100%;padding-top: 10px; margin-bottom: 10px;}
    .c_img{float: left;width: 15%;margin: 0 auto;text-align: center;padding-top: 20px;}
    .p1{height: 25px;line-height: 25px; padding: 0;margin: 0;font-size:12px;}
    .p2{line-height: 25px;padding: 0;margin: 0;font-size:12px;}
    .p3{height: 25px;line-height: 25px;padding: 0;margin: 0;font-size:12px; padding-bottom: 15px;}
    .c_left{float: left;width: 85%;}
    .weui-tabbar__i{font-family: "Microsoft Yahei";}
    #zan{font-size:16px;width: 50px;padding-top:7px;}
    #collect{font-size:16px;width:60px;padding-top:7px;}
    #xpl{font-size:16px;width:60px;padding-top:7px;}
    #comment_list{border-top:1px #ccc solid;padding-top: 10px;}
    .weui-media-box_appmsg {align-items:flex-start; }
    .weui-media-box_appmsg .weui-media-box__hd{width:45px;height:45px;margin-right: .2em;}
    .weui-media-box_appmsg .weui-media-box__thumb{width:40px;height:40px;border:1px #ccc solid; border-radius:20px; top:0px; margin-right: .2em;}
    .weui-media-box__title{font-size: 14px;}
    .time{font-size:12px;padding-bottom: 4px;}
    .black{color:#000;font-size:13px;}
    .fa-thumbs-up{color:#2fab87;}
    .fa-heart{color:#2fab87;}
    .cnt p img{width:100%;}


    .form-control {
        background-color: #FFF;
        background-image: none;
        border: 1px solid #e5e6e7;
        border-radius: 1px;
        color: inherit;
        display: block;
        padding: 6px 12px;
        -webkit-transition: border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;
        transition: border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;
        width: 70%;
        font-size: 14px;
    }

</style>
</head>
<body style="background:#fff;">


<div id="content" class="content" >
    <div class="title"><?php echo $article['title']; ?></div>
    <div class="title1"><?php echo $author; ?> &nbsp; &nbsp; <?php echo date("m-d H:i",$article['create_time']); ?> &nbsp; &nbsp;&nbsp; &nbsp; 阅读量:<?php echo $article['views']; ?></div>
    <!--<div><img src="/uploads/images/<?php echo $article['photo']; ?>" width="100%"></div>-->
    <div><?php echo $article['content']; ?></div>
    <input id="now" type="hidden" value="">
    <input id="all" type="hidden" value="<?php echo $all; ?>">


    <?php if($article['vote_id']>0): ?>
    <div>
        <div class="weui-flex" style="text-align: center;margin-top:20px;">
            <div class="weui-flex__item"><div class="placeholder" style="font-size: 18px;"><?php echo $vote['title']; ?></div></div>
        </div>
        <?php if($imgs==1): if(is_array($choose) || $choose instanceof \think\Collection || $choose instanceof \think\Paginator): if( count($choose)==0 ) : echo "" ;else: foreach($choose as $key=>$v): ?>
        <div style="width: 33%;float: left; text-align: center;font-size: 12px; padding-bottom: 15px;" >
            <img src="/uploads/images/<?php echo $v['img']; ?>" style="width: 70%; border-radius:50%;  ">
            <p><?php echo $v['num']; ?>票</p>
            <p style="line-height: 19px;vertical-align: middle;"><input type="checkbox" name="data[choose]" value="<?php echo $v['id']; ?>"><span style="position: relative;top: -2px;"><?php echo $v['choose']; ?><?php echo $v['desc']; ?></span></p>
        </div>
        <?php endforeach; endif; else: echo "" ;endif; endif; if($imgs==0): if(is_array($choose) || $choose instanceof \think\Collection || $choose instanceof \think\Paginator): if( count($choose)==0 ) : echo "" ;else: foreach($choose as $key=>$v): ?>
        <div class="weui-flex" style="padding: 5px 12px;">
            <div><div class="placeholder" ><input type="checkbox" name="data[choose]" value="<?php echo $v['id']; ?>" style="position: relative;top: 1px;"></div></div>
            <div class="weui-flex__item"><div class="placeholder" style="text-align: left;padding-left: 5px;"><?php echo $v['choose']; ?><?php echo $v['desc']; ?></div></div>
            <div><div class="placeholder"><?php echo $v['num']; ?>票</div></div>
        </div>
        <?php endforeach; endif; else: echo "" ;endif; endif; ?>
        <div style="padding: 20px 50px;clear: both;"><a href="javascript:;" id="smt" class="weui-btn weui-btn_primary"> 提交投票</a></div>
    </div>
    <?php endif; if($article['baoming_id']>0): ?>
    <div class="weui-flex" style="text-align: center;margin-top:20px;">
        <div class="weui-flex__item"><div class="placeholder" style="font-size: 18px;"><?php echo $baoming['title']; ?></div></div>
    </div>
    <form class="form-horizontal" name="userAdd" id="userAdd" method="post" action="<?php echo url('Usercenter/baomingajax'); ?>">
    <?php if(is_array($xiangmu) || $xiangmu instanceof \think\Collection || $xiangmu instanceof \think\Paginator): if( count($xiangmu)==0 ) : echo "" ;else: foreach($xiangmu as $key=>$v): ?>
        <div id="baoming_info">
                <div class="weui-flex" style="padding: 5px 12px;">
                    <div><div class="placeholder" style="padding-left: 10px;" ><?php echo $v['name']; ?></div></div>
                    <div class="weui-flex__item"><div class="placeholder" style="text-align: left;padding-left: 5px;"><input type="text" name="<?php echo $v['title']; ?>"  class="form-control"    > </div></div>
                    <div><div class="placeholder"></div></div>
                </div>
        </div>
    <?php endforeach; endif; else: echo "" ;endif; ?>

    <input type="hidden" value="<?php echo $article['baoming_id']; ?>" name="baoming_id">
    <div style="padding: 20px 50px;clear: both;">
        <button type="submit"  class="weui-btn weui-btn_primary" >提交</button>
    </div>
    </form>
    <?php endif; ?>




    <div class="weui-panel weui-panel_access">
        <div>作者信息：</div>
        <div class="weui-panel__bd">

            <a href="<?php echo url('user/user_info',array('user_id'=>$user_info['id'])); ?>" class="weui-media-box weui-media-box_appmsg">
                <div class="weui-media-box__hd">
                    <img class="weui-media-box__thumb" src="/uploads/face/<?php echo $user_info['head_img']; ?>" onerror="this.src='/static/admin/images/head_default.gif'" style="width:42px;height:42px;border-radius: 50%;">
                </div>
                <div class="weui-media-box__bd">
                    <h4 class="weui-media-box__title"><?php echo $user_info['nickname']; ?></h4>
                    <p class="weui-media-box__desc"><?php echo $user_info['desc']; ?></p>
                </div>
            </a>
        </div>
    </div>








    <?php if(is_array($tp_article) || $tp_article instanceof \think\Collection || $tp_article instanceof \think\Paginator): if( count($tp_article)==0 ) : echo "" ;else: foreach($tp_article as $key=>$val): ?>
    <div style="margin-top:15px;">
            <div style="border-top:1px #e5e5e5 solid;">修改来自:<?php echo $val['name']; ?></div>
            <div>标题:<?php echo $val['title']; ?></div>
            <div>描述:<?php echo $val['remark']; ?></div>
            <div class="cnt">内容:<?php echo $val['content']; ?></div>
    </div>
    <?php endforeach; endif; else: echo "" ;endif; ?>






    <div style="margin-top:20px;">评论&nbsp;<?php echo $commentall; ?></div>
    <div class="weui-panel weui-panel_access">

        <div class="weui-panel__bd">

            <script id="list-template" type="text/html">
                {{# for(var i=0;i<d.length;i++){  }}
                        <a href="/index/user/user_info/user_id/{{d[i].user_id}}.html" class="weui-media-box weui-media-box_appmsg">
                            <div class="weui-media-box__hd">
                                <img class="weui-media-box__thumb" src="/uploads/face/{{d[i].head_img}}" alt="" >
                            </div>
                            <div class="weui-media-box__bd">
                                <h4 class="weui-media-box__title">{{d[i].nickname}}</h4>
                                <p class="weui-media-box__desc time">{{d[i].addtime}}</p>
                                <p class="weui-media-box__desc black">{{d[i].content}}</p>

                            </div>
                        </a>
                {{# } }}
            </script>

            <div id="list-content"></div>
        </div>

    </div>



    <div style="height: 50px;">&nbsp;</div>
</div>

<!--<div  id="foot" class="foot" >-->
            <!--<div class="footli">-->
                <!--<div>-->
            <!--<div class="fleft" ><a   href="javascript:;" onclick="dianzan(<?php echo $article['id']; ?>);"><img <?php if($is_zan == 1): ?> src="__STATIC__/index/images/zan.png" <?php else: ?> src="__STATIC__/index/images/zan1.png" <?php endif; ?> style="width:30px;" id="zan"></a></div>-->
            <!--<div class="fleft" id="zan1"><?php echo $zan; ?></div>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="footli">-->
                <!--<div>-->
            <!--<div class="fleft"><a  href="javascript:;" onclick="shoucang(<?php echo $article['id']; ?>);">-->
                <!--<img <?php if($is_collect == 1): ?> src="__STATIC__/index/images/collect.png" <?php else: ?> src="__STATIC__/index/images/collect1.png" <?php endif; ?> style="width:30px;" id="collect">-->
            <!--</a></div>-->
            <!--<div class="fleft" id="collect1" ><?php echo $collect; ?></div>-->
                <!--</div>-->
             <!--</div>-->
    <!--<a  href="javascript:;" onclick="pinglun(<?php echo $user_id; ?>)"><div class="footli pinglun" > 评  论</div></a>-->
<!--</div>-->

<div class="weui-tabbar footer" id="foot">
    <a href="javascript:;" class="weui-tabbar__item" onclick="dianzan(<?php echo $article['id']; ?>);" style=" border-right:1px #ccc solid;" >
                    <span style="display: inline-block;position: relative;vertical-align: middle;">
                            <i id="zan" class="fa <?php if($is_zan == 1): ?>fa-thumbs-up<?php else: ?>fa-thumbs-o-up<?php endif; ?> ">&nbsp;&nbsp;赞</i>
                        </span>

        <!--<p class="weui-tabbar__label" id="zan1"><?php echo $zan; ?></p>-->
    </a>
    <a href="javascript:;" class="weui-tabbar__item" onclick="shoucang(<?php echo $article['id']; ?>);" >

                   <span style="display: inline-block;position: relative;vertical-align: middle;">
                            <i id="collect" class="fa <?php if($is_collect == 1): ?>fa-heart<?php else: ?>fa-heart-o<?php endif; ?> ">&nbsp;&nbsp;收藏</i>
            </span>
        <!--<p class="weui-tabbar__label" id="collect1">收藏</p>-->

        </a>
    <a  href="javascript:;" class="weui-tabbar__item " onclick="pinglun(<?php echo $user_id; ?>)" style=" border-left:1px #ccc solid;">


            <span style="display: inline-block;position: relative;vertical-align: middle;">
                            <i id="xpl" class="fa fa-comment-o weui-tabbar__icon">&nbsp;&nbsp;评论 </i>
        </span>
    </a>
</div>

<div id="pinglun"  style="display: none;">
    <div style="height: 45px; line-height: 45px; border-bottom:1px #ccc solid;">
        <div style="float: left;width:15%;text-align: center;"><a href="javascript:;" onclick="cancel_pinglun()" style="color: #ccc;"><i class="fa fa-arrow-left"></i></a></div>
        <div style="float: left;width:70%;text-align: center">发表评论</div>
        <div style="float: left;width:15%;text-align: center;font-size:14px;"><a href="javascript:;" onclick="send_pinglun(<?php echo $user_id; ?>,<?php echo $id; ?>)"><span style="border:1px #ccc solid;padding: 4px 8px;border-radius: 5px;color: #ccc;">发表</span></a></div>
    </div>

    <div style="width: 100%;height:250px;background:#fff;border:1px #ccc solid;" id="pinglun_msg"  contenteditable="true">

    </div>

</div>
<script type="text/javascript">
    AjaxPage();
    $(window).scroll(
            function() {
                var scrollTop = $(this).scrollTop();
                var scrollHeight = $(document).height();
                var windowHeight = $(this).height();
                if (scrollTop + windowHeight == scrollHeight) {
                    AjaxPage();
                }
            });


    function AjaxPage(){
       var now =  $('#now').val();
       var all =  $('#all').val();
        var article_id = '<?php echo $id; ?>';
        if(now==''){
            now =1 ;
        }
        if(now<=all){

            console.log(article_id+'|'+now);

            $.post('<?php echo url("index/comment_list"); ?>',
                    {id:article_id,page:now},
                    function(data){
                        if(data=='') {

                        }else{
                            console.log(data);

                            var tpl = document.getElementById('list-template').innerHTML;

                            console.log(tpl);

                            laytpl(tpl).render(data, function(html){
                                // document.getElementById('list-content').innerHTML = html;
                                console.log('ddd'+html);
                                $('#list-content').append(html);
                            });

//                            $html = '';
//                            for(c in data.list){
//                                //data.list[c].addtime
////                                $html = $html + "<div class='comm' ><div class='c_img'><img src='/uploads/face/"+data.list[c].head_img+"' width='30px'></div><div class='c_left'><p class='p1' style=''>"+data.list[c].nickname+"</p><p class='p2' style=''>"+data.list[c].content+"</p><p class='p3' style=''>"+data.list[c].addtime+"</p></div></div>";
//
//
//                            }
//
//                            $("#pingluns").append($html);

                        }
                    });

           var next = now + 1;
            $('#now').val(next) ;

        }
    }

    function dianzan(id){
        $.post('<?php echo url("index/zan_status"); ?>',
                {id:id},
                function(data){
                    if(data.code==11){
                        layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                        window.location.href="<?php echo url('user/login'); ?>";
                    }else {
                        if(data.code==1){

                                $('#zan').removeClass('fa-thumbs-o-up');
                                $('#zan').addClass('fa-thumbs-up');


//                            $('#zan').attr('src','__STATIC__/index/images/zan.png') ;
//                            document.getElementById('zan1').innerHTML = data.count;
                            layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                        }else{
                            $('#zan').removeClass('fa-thumbs-up');
                            $('#zan').addClass('fa-thumbs-o-up');
//                            $('#zan').attr('src','__STATIC__/index/images/zan1.png') ;
//                            document.getElementById('zan1').innerHTML = data.count;
                            layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                        }
                    }

                });
    }
    function shoucang(id){
        $.post('<?php echo url("index/collect_status"); ?>',
                {id:id},
                function(data){
                    if(data.code==11){
                        layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                        window.location.href="<?php echo url('user/login'); ?>";
                    }else{
                        if(data.code==1){
                            $('#collect').removeClass('fa-heart-o');
                            $('#collect').addClass('fa-heart');
                            layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                        }else{

                            $('#collect').removeClass('fa-heart');
                            $('#collect').addClass('fa-heart-o');
                            layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                        }
                    }
                });
    }

    function pinglun(i){
        if(i==0){
            layer.msg('您尚未登录！',{icon:5,time:1500,shade: 0.1,});
            window.location.href="<?php echo url('user/login'); ?>";
        }


        $('#content').hide();
        $('#foot').hide();
        $('#pinglun').show();

    }

    function cancel_pinglun(){

        $('#pinglun').hide();
        $('#content').show();
        $('#foot').show();



    }

    function send_pinglun(user_id,article_id){
        var content = document.getElementById('pinglun_msg').innerHTML;
        $.post('<?php echo url("index/article_comment"); ?>',
                {id:article_id,user_id:user_id,content:content},
                function(data){
                    if(data.code==1) {
                        layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                        $html ="<div class='comm' ><div class='c_img'><img src='"+data.list.img+"' width='30px'></div><div class='c_left'><p class='p1' style=''>"+data.list.nickname+"</p><p class='p2' style=''>"+data.list.content+"</p><p class='p3' style=''>"+data.list.addtime+"</p></div></div>";

                        $("#pingluns").prepend($html);

                        $('#pinglun').hide();
                        $('#content').show();
                        $('#foot').show();

                    }else{
                        layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                    }
                });
    }



    $(document).ready(function() {
        $('p img').each(function() {
            var maxWidth = $(window).width()-20;
            var ratio = 0;  // 缩放比例
            var width = $(this).width();    // 图片实际宽度
            var height = $(this).height();  // 图片实际高度

            if(width > maxWidth){
                ratio = maxWidth / width;   // 计算缩放比例
                $(this).css("width", maxWidth); // 设定实际显示宽度
                height = height * ratio;    // 计算等比例缩放后的高度
                $(this).css("height", height);  // 设定等比例缩放后的高度
            }

        });
    });





            $('#smt').click(

                    function(){
                        var aa = ',';
                        bb = 0;
                        $("input[name='data[choose]']:checkbox:checked").each(function(){
                            aa+=$(this).val()+',';
                            bb = bb+1;

                        });

                        console.log(aa);
                        console.log(bb);

                        cc= '<?php echo $vote['max_num']; ?>';
                        if(bb>cc){
                            layer.msg('每次投票最多选'+cc+'项',{icon:5,time:1000,shade: 0.1,});
                            return false;
                        }
                        if(aa==','){
                            layer.msg('请勾选你想要投票的选项',{icon:5,time:1000,shade: 0.1,});
                            return false;
                        }
                        var id = '<?php echo $article['vote_id']; ?>';
                        $.post('<?php echo url("usercenter/real_vote"); ?>',
                                {id:id,choose:aa},
                                function(data){

                                    console.log(data);

                                    if(data.code==1) {
                                        layer.msg(data.msg,{icon:6,time:1000,shade: 0.1,});
                                    }else{
                                        layer.msg(data.msg,{icon:5,time:1000,shade: 0.1,});
                                        if(data.code==-11){
                                            window.location.href="<?php echo url('user/login'); ?>";
                                        }
                                    }
                                });
                    }
            );


    $(function(){
        $('#userAdd').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){
            var cv = 'www';
            $("#baoming_info input[type='text']").each(function () {
                if ($(this).val() == "") {
                     cv = 'qqq';
                }
            });

            if(cv=='qqq'){
                layer.msg('请完善报名信息后在提交', {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }



        }

        function complete(data){
            console.log(data);
            if(data.code == 1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });

</script>



</body>
</html>